home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qlib205.zip / QLIB.ZIP / TEST / GRAFIX-G.ASM < prev    next >
Assembly Source File  |  1997-06-05  |  5KB  |  214 lines

  1. .data
  2.   us mouse_user <>
  3. .code
  4. ;this proc is called every time the mouse moves or a button is pressed/released
  5. ;NOTE:this is called in an IRQ!!  (so don't do any file IO, ok? - just
  6. ;don't do anything that calls DOS)
  7. user proc
  8.   mov ax,us.x
  9.   mov bx,us.y
  10.   mov cx,us.but
  11. ;the following changes the mouse ptr if it's in the BOX
  12.   .if (ax>100) && (ax<200) && (bx>110) && (bx<199)
  13.     .if bpp==8
  14.       callp mouse_setcursor,offset cursor8a,9,9,0,0
  15.     .elseif bpp==16 || bpp==15
  16.       callp mouse_setcursor,offset cursor16a,8,8,0,0
  17.     .elseif bpp==24
  18.       callp mouse_setcursor,offset cursor24a,8,8,0,0
  19.     .else
  20.       callp mouse_setcursor,offset cursor32a,8,8,0,0
  21.     .endif
  22.   .else
  23.     .if bpp==8
  24.       callp mouse_setcursor,offset cursor8b,9,9,0,0
  25.     .elseif bpp==16 || bpp==15
  26.       callp mouse_setcursor,offset cursor16b,8,8,0,0
  27.     .elseif bpp==24
  28.       callp mouse_setcursor,offset cursor24b,8,8,0,0
  29.     .else
  30.       callp mouse_setcursor,offset cursor32b,8,8,0,0
  31.     .endif
  32.   .endif
  33.   ret
  34. user endp
  35.  
  36. exit_error proc,aa:dword
  37.     callp printf,aa
  38.     callp exit,0
  39. exit_error endp
  40.  
  41. exit_on_null macro aa:REQ
  42.   .if eax==NULL
  43.     callp exit_error,aa
  44.   .endif
  45. endm
  46.  
  47. exit_on_error macro aa:REQ
  48.   .if eax==ERROR
  49.     callp exit_error,aa
  50.   .endif
  51. endm
  52.  
  53. grafix_test proc
  54.   call clrscr
  55. top:
  56.   callp printf,"Grafix Mode Tests\n\n"
  57.   callp printf,"Enter X Res (ie: 320,640,800,etc.) :>"
  58.   callp gets,offset tmpstr
  59.   callp atol,offset tmpstr
  60.   mov x,eax
  61.   callp printf,"Enter Y Res (ie: 200,480,600,etc.) :>"
  62.   callp gets,offset tmpstr
  63.   callp atol,offset tmpstr
  64.   mov y,eax
  65.   callp printf,"Enter BPP (ie: 8,16,24,etc.) :>"
  66.   callp gets,offset tmpstr
  67.   callp atol,offset tmpstr
  68.   mov bpp,al
  69.   .if ! (al==32 || al==24 || al==16 || al==15 || al==8)
  70.     jmp not_avail
  71.   .endif
  72.   .if x<320 || y<200 || bpp<8
  73.     jmp not_avail
  74.   .endif
  75.   mov eax,x
  76.   mul y
  77.   .if bpp == 24
  78.     lea eax,[eax+eax*2]  ;*3
  79.   .elseif bpp == 32
  80.     shl eax,2   ;*4
  81.   .elseif bpp==16 || bpp==15
  82.     shl eax,1   ;*2
  83.   .endif
  84.  
  85.   callp calloc,eax,1
  86.   exit_on_null "Out of memory"
  87.   mov tvid,eax
  88.   callp g_setbuf,tvid
  89.  
  90.   callp mouse_setuser,offset user,offset us
  91.  
  92.   .if bpp==24
  93.     callp mouse_setcursor,offset cursor24a,9,9,0,0
  94.     callp g_loadfnt,offset font24
  95.   .elseif bpp==32
  96.     callp mouse_setcursor,offset cursor32a,9,9,0,0
  97.     callp g_loadfnt,offset font32
  98.   .elseif bpp==16 || bpp==15
  99.     callp mouse_setcursor,offset cursor16a,9,9,0,0
  100.     callp g_loadfnt,offset font16
  101.   .else
  102.     callp mouse_setcursor,offset cursor8a,9,9,0,0
  103.     callp g_loadfnt,offset font8
  104.   .endif
  105.   mov fontbuf,eax
  106.   exit_on_error "Unable to load FONT file!"
  107.  
  108.   callp g_getmode,x,y,bpp
  109.   .if eax==ERROR
  110. not_avail:
  111.     callp printf,"\nVideo mode not supported!\n Press a key..."
  112.     call wait4key
  113.     ret
  114.   .endif
  115.   mov mode,al
  116.   callp g_setmode
  117.  
  118.   .if bpp==8
  119.     callp g_setfntcolor,4
  120.   .else
  121.     callp g_setfntcolor,0ffffffffh
  122.   .endif
  123.  
  124.   callp g_printf,10,0,"Video Type ="
  125.   .if mode==G_VGA
  126.     callp g_printf,110,0,"VGA"
  127.   .elseif mode==G_VESA
  128.     callp g_printf,110,0,"VESA"
  129.   .elseif mode==G_MODEX
  130.     callp g_printf,110,0,"ModeX"
  131.   .else
  132.     callp g_printf,110,0,"???"
  133.   .endif
  134.   .if bpp==8
  135.     callp g_setfntcolor,7
  136.   .else
  137.     callp g_setfntcolor,0b0b0b0b0h
  138.   .endif
  139.  
  140.   callp g_printf,10,10,"Video Mode %dx%d %dbit",x,y,bpp
  141.  
  142.   callp g_printxy,10,30,"Press keys to move on..."
  143.   callp g_printxy,10,50,"Mouse Window : (50,50)-(100,100)"
  144.   .if bpp==24 || bpp==32
  145.     mov eax,0ffffffh  ;24bit color
  146.   .else
  147.     mov eax,15
  148.   .endif
  149.   callp g_box,100,110,200,199,eax
  150.   callp g_printxy,102,112,"User Defined"
  151.   callp g_printxy,102,122," area"
  152.   call g_copy
  153.  
  154.   callp mouse_setwin,50,50,100,100  ;must reset size before mouse_on
  155.   callp mouse_setpos,50,50
  156.   callp mouse_setspd,1,1
  157.   call mouse_on
  158.   call wait4key
  159.  
  160.   callp g_printxy,10,60,"Full Window"
  161.   call g_copy
  162.   mov ebx,x
  163.   mov ecx,y
  164.   dec ebx
  165.   dec ecx
  166.   callp mouse_setwin,0,0,ebx,ecx
  167.   call wait4key
  168.  
  169.   callp g_printxy,10,70,"Half Speed"
  170.   call g_copy
  171.   callp mouse_setspd,2,2
  172.   call wait4key
  173.  
  174.   callp g_printxy,10,80,"Move mouse to (100,100)"
  175.   .if bpp>8
  176.     callp g_printxy,10,90,"Press a key to quit"
  177.   .endif
  178.   call g_copy
  179.   callp mouse_setpos,100,100
  180.   call wait4key
  181.  
  182.   .if bpp==8
  183.     callp g_printxy,10,90,"Hold in buttons to change color:"
  184.     callp g_printxy,10,100,"Press a key to quit"
  185.     call g_copy
  186.     mov ccol,63
  187.     .repeat
  188.       mov cx,us.but
  189.       .if (cl & 1)
  190.         inc ccol
  191.       .endif
  192.       .if (cl & 2)
  193.         dec ccol
  194.       .endif
  195.       .if ccol==64
  196.         mov ccol,0
  197.       .elseif ccol==255
  198.         mov ccol,63
  199.       .endif
  200.  
  201.       callp g_setcol,1,0,0,ccol
  202.       call kbhit
  203.     .until al
  204.     call getch
  205.   .endif
  206. done:
  207.   call mouse_off
  208.   callp g_setmode,3
  209.   callp free,tvid
  210.   callp free,fontbuf
  211.   ret
  212. grafix_test endp
  213.  
  214.